home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume11 / bt / patch1 < prev   
Encoding:
Internet Message Format  |  1990-12-11  |  34.5 KB

  1. Path: uunet!kddlab!trl!rdmei!ptimtc!olivea!apple!usc!cs.utexas.edu!uwm.edu!ogicse!zephyr.ens.tek.com!tekred!daemon!billr
  2. From: billr@daemon.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v11i077:  bt - Broken Throne, multiplayer realtime conquest game, Patch1
  5. Message-ID: <6638@tekred.CNA.TEK.COM>
  6. Date: 1 Dec 90 01:24:11 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 1167
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: Tom Boutell <boutell@freezer.it.udel.edu>
  12. Posting-number: Volume 11, Issue 77
  13. Archive-name: bt/Patch1
  14. Patch-To: bt: Volume 11, Issue 75-76
  15. Environment: INET sockets, curses
  16.  
  17.     [This patch brings bt to version 1.01. Unpack this file
  18.      and feed to patch(1), or feed directly to patch in your
  19.      bt source directory.  -br]
  20.  
  21. #! /bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of shell archive."
  28. # Contents:  patches01
  29. # Wrapped by billr@saab on Fri Nov 30 17:18:08 1990
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'patches01' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'patches01'\"
  33. else
  34. echo shar: Extracting \"'patches01'\" \(32580 characters\)
  35. sed "s/^X//" >'patches01' <<'END_OF_FILE'
  36. X*** ../../bt/Makefile    Mon Nov 12 13:10:55 1990
  37. X--- Makefile    Sat Nov 24 15:38:43 1990
  38. X***************
  39. X*** 4,9 ****
  40. X--- 4,14 ----
  41. X  btserver: bt.o pack.o interface.o
  42. X      cc bt.o pack.o interface.o -o btserver
  43. X  
  44. X+ btrobot: robot.o pack.o
  45. X+     cc robot.o pack.o -o btrobot
  46. X+ 
  47. X+ robot.o: robot.c
  48. X+     cc -c -g robot.c
  49. X  client.o: client.c
  50. X      cc -c -g client.c
  51. X  pack.o: pack.c
  52. X*** ../../bt/README    Tue Nov 20 12:48:35 1990
  53. X--- README    Sat Nov 24 11:05:38 1990
  54. X***************
  55. X*** 19,30 ****
  56. X  If "make btserver" fails, I will be very, very surprised. Please mail me
  57. X  the details (boutell@freezer.it.udel.edu).
  58. X  
  59. X  If "make btclient" fails, I won't be so surprised. This is because the game
  60. X  plays games with stdin to find out if there are characters waiting or not.
  61. X! This shouldn't vary from one Unix to another but it probably will anyway.
  62. X  If you can fix it for your machine, great; mail me what you did so I can
  63. X  create a compile- time option for that machine. One possible replacement
  64. X  approach for System V folks is to use the nodelay() routine of Curses.
  65. X  (This routine is missing in SunOS curses. Ahrgh.) Of course, if the code
  66. X  runs as- is, you're golden!
  67. X  
  68. X--- 19,67 ----
  69. X  If "make btserver" fails, I will be very, very surprised. Please mail me
  70. X  the details (boutell@freezer.it.udel.edu).
  71. X  
  72. X+ One exception: your libraries may not support the usleep call. In that
  73. X+ case, replace it with a call to sleep(1), or remove it altogether. The
  74. X+ prior method is greatly preferred. Even better would be to sleep for
  75. X+ 1/10th of a second in a way that is appropriate for your system. Please
  76. X+ do NOT simply insert a counting loop since the only purpose of this line
  77. X+ is to give time back to the system.
  78. X+ 
  79. X  If "make btclient" fails, I won't be so surprised. This is because the game
  80. X  plays games with stdin to find out if there are characters waiting or not.
  81. X! If you are running a BSD unix, you should not have problems under this
  82. X! release. If you are running under System V, you almost certainly will.
  83. X  If you can fix it for your machine, great; mail me what you did so I can
  84. X  create a compile- time option for that machine. One possible replacement
  85. X  approach for System V folks is to use the nodelay() routine of Curses.
  86. X  (This routine is missing in SunOS curses. Ahrgh.) Of course, if the code
  87. X  runs as- is, you're golden!
  88. X+ 
  89. X+ One easy fix you may have to make: if your compiler complains that errno
  90. X+ is undefined, insert "int errno;" at main level in client.c. This really
  91. X+ shouldn't be necessary, but sometimes it is.
  92. X+ 
  93. X+ CHANGES IN VERSION 1.01
  94. X+ 
  95. X+ - Input is now handled in a way that should be generic BSD.
  96. X+ - The 'h' key no longer summons help; this is now done with the ? key,
  97. X+   shifted or not ('/').
  98. X+ - Certain strange compiler errors in interface.c are resolved. (Some
  99. X+   compilers were treating =* as meaning something other than "equal to
  100. X+   the dereferenced value of." One even treated =-1 as meaning something
  101. X+   other than equal to -1!) Parentheses in judicious places solved these.
  102. X+ - You can now move the cursor while "thinking" about what command to enter.
  103. X+   The only time you can't move the cursor is while entering a text
  104. X+   message or typing a number of troops.
  105. X+ - It is now easier to tell whether you are in command mode or entering
  106. X+   a location.
  107. X+ - You can now specify a different port number. This is given as a second
  108. X+   argument to btserver, and also to btclient. This permits multiple games
  109. X+   on one machine.
  110. X+ - 'M' (capitalized) now redraws a Messy screen after a talk message, etc.
  111. X+ - There is now an opening message while the map is being transmitted.
  112. X+ - The number of players must be inputted on the command line. An old
  113. X+   undocumented feature of the server was the ability to prompt for this,
  114. X+   removed to make the new port number question unambiguous.
  115. X+ 
  116. X+ 
  117. X  
  118. X*** ../../bt/bt.c    Fri Nov 16 12:34:12 1990
  119. X--- bt.c    Sat Nov 24 15:44:15 1990
  120. X***************
  121. X*** 24,29 ****
  122. X--- 24,30 ----
  123. X    int number;
  124. X    int x,y;
  125. X    int flag;
  126. X+   int portnumber;
  127. X    long lasttime;
  128. X    long newtime;
  129. X    char specificspace[256];
  130. X***************
  131. X*** 30,40 ****
  132. X    char *specific;
  133. X    int offset;
  134. X    printf("Broken Throne server program launching...\n");
  135. X!   if (argc>1) 
  136. X      totalplayers=atoi(argv[1]);
  137. X    else {
  138. X!     printf("Number of players? ");
  139. X!     scanf("%d",&totalplayers); 
  140. X    }
  141. X    if (totalplayers<1 || totalplayers>_MAXPLAYERS) {
  142. X       printf("Number of players should be between 1 and %d.\n",_MAXPLAYERS);
  143. X--- 31,50 ----
  144. X    char *specific;
  145. X    int offset;
  146. X    printf("Broken Throne server program launching...\n");
  147. X!   portnumber=2727;
  148. X!   if (argc>1) {
  149. X      totalplayers=atoi(argv[1]);
  150. X+     if (argc>2) {
  151. X+       portnumber=atoi(argv[2]);
  152. X+       if (portnumber<1000 || portnumber>9999) {
  153. X+         printf("Port number must be between 1000 and 9999.\n");
  154. X+         exit(1);
  155. X+       }
  156. X+     }
  157. X+   }
  158. X    else {
  159. X!     printf("Usage: btserver #ofplayers <port# (optional)>\n");
  160. X!     exit(1);
  161. X    }
  162. X    if (totalplayers<1 || totalplayers>_MAXPLAYERS) {
  163. X       printf("Number of players should be between 1 and %d.\n",_MAXPLAYERS);
  164. X***************
  165. X*** 45,51 ****
  166. X    specific=specificspace;
  167. X    time(&lasttime);
  168. X    srand(lasttime % 1024); /* Get a new random # seed */
  169. X!   setupinterface();
  170. X    signal(SIGTERM,endprogram);
  171. X    broadcast(_STARTUP,(void*)NULL);
  172. X    setupmap();
  173. X--- 55,61 ----
  174. X    specific=specificspace;
  175. X    time(&lasttime);
  176. X    srand(lasttime % 1024); /* Get a new random # seed */
  177. X!   setupinterface(portnumber);
  178. X    signal(SIGTERM,endprogram);
  179. X    broadcast(_STARTUP,(void*)NULL);
  180. X    setupmap();
  181. X***************
  182. X*** 415,422 ****
  183. X    map[at.x][at.y].lastuse=currenttime;
  184. X    population=0;
  185. X    if (chance>((rand() / 100) % 20)) {
  186. X!     for (y=-1; (y<=1); y++) {
  187. X!       for (x=-1; (x<=1); x++) {
  188. X          if (legal(at.x+x,at.y+y)) {
  189. X            if ((((map[at.x][at.y].terrain!=2) && (map[at.x][at.y].terrain!=5)) ||
  190. X                ((x==0) && (y==0))) && ((map[at.x][at.y].owner==currentplayer) ||
  191. X--- 425,432 ----
  192. X    map[at.x][at.y].lastuse=currenttime;
  193. X    population=0;
  194. X    if (chance>((rand() / 100) % 20)) {
  195. X!     for (y=(-1); (y<=1); y++) {
  196. X!       for (x=(-1); (x<=1); x++) {
  197. X          if (legal(at.x+x,at.y+y)) {
  198. X            if ((((map[at.x][at.y].terrain!=2) && (map[at.x][at.y].terrain!=5)) ||
  199. X                ((x==0) && (y==0))) && ((map[at.x][at.y].owner==currentplayer) ||
  200. X***************
  201. X*** 447,457 ****
  202. X  }
  203. X  
  204. X  void setupmap() {
  205. X! /* Not yet safe; will keep trying by means of rand to position a
  206. X!    player indefinitely if it runs out of space or hits a numeric
  207. X!    ugly. Can be remedied by sweeping the map starting from one
  208. X!    random point. Map generator is not optimized well. */
  209. X! 
  210. X    int altitude[_MAPX][_MAPY];
  211. X    int newaltitude[_MAPX][_MAPY];
  212. X    int x,y,subx,suby;
  213. X--- 457,464 ----
  214. X  }
  215. X  
  216. X  void setupmap() {
  217. X! /* Relatively safe, but if there isn't room for the number of players
  218. X!    the game may lock up. */
  219. X    int altitude[_MAPX][_MAPY];
  220. X    int newaltitude[_MAPX][_MAPY];
  221. X    int x,y,subx,suby;
  222. X***************
  223. X*** 463,468 ****
  224. X--- 470,477 ----
  225. X    location newhex;
  226. X    int placement;
  227. X    full=0;
  228. X+   sprintf(playertext,"Generating the map...");
  229. X+   broadcast(_TEXT,(void*)playertext);
  230. X    for (y=0; (y<_MAPY); y++) {
  231. X      for (x=0; (x<_MAPX); x++) {
  232. X        altitude[x][y]=0;
  233. X***************
  234. X*** 522,529 ****
  235. X          newaltitude[x][y]=altitude[x][y];
  236. X          if (altitude[x][y]==0) {
  237. X            totalaltitude=0;
  238. X!           for (suby=-1; (suby<=1); suby++) {
  239. X!             for (subx=-1; (subx<=1); subx++) {   
  240. X                if (legal(x+subx,y+suby)) 
  241. X                  totalaltitude+=altitude[x+subx][y+suby];
  242. X              }
  243. X--- 531,538 ----
  244. X          newaltitude[x][y]=altitude[x][y];
  245. X          if (altitude[x][y]==0) {
  246. X            totalaltitude=0;
  247. X!           for (suby=(-1); (suby<=1); suby++) {
  248. X!             for (subx=(-1); (subx<=1); subx++) {   
  249. X                if (legal(x+subx,y+suby)) 
  250. X                  totalaltitude+=altitude[x+subx][y+suby];
  251. X              }
  252. X*** ../../bt/bt.doc    Tue Nov 20 12:44:45 1990
  253. X--- bt.doc    Sat Nov 24 11:12:30 1990
  254. X***************
  255. X*** 82,93 ****
  256. X  order to keep his screen from being "munged" as the server announces
  257. X  players.
  258. X  
  259. X  Once the client is launched, a blank map will be displayed. Within a moment
  260. X  or two it should be replaced by the full map; be patient if there are
  261. X  several players.
  262. X  
  263. X  When the game first begins, the player is told which lowercase letter
  264. X! belongs to them. Initially the player controls one city and no troops.
  265. X  In order to acquire troops, the r (recruit) command should be used
  266. X  immediately. A cursor will appear at the city's location. This cursor
  267. X  can be moved with the standard vi/ moria/ hack movement keys:
  268. X--- 82,103 ----
  269. X  order to keep his screen from being "munged" as the server announces
  270. X  players.
  271. X  
  272. X+ OTHER PORT NUMBERS
  273. X+ 
  274. X+ If you do not want to use the default port (2727), or if there is another
  275. X+ BT game in progress on the same machine, you will need to specify a port
  276. X+ number. Port numbers should be between 1000 and 9999, the same on both
  277. X+ client and server. Enter the port number after the number of players
  278. X+ or machine address, and before the & in the case of the server.
  279. X+ 
  280. X+ ONCE THE GAME STARTS:
  281. X+ 
  282. X  Once the client is launched, a blank map will be displayed. Within a moment
  283. X  or two it should be replaced by the full map; be patient if there are
  284. X  several players.
  285. X  
  286. X  When the game first begins, the player is told which lowercase letter
  287. X! represents them. Initially the player controls one city and no troops.
  288. X  In order to acquire troops, the r (recruit) command should be used
  289. X  immediately. A cursor will appear at the city's location. This cursor
  290. X  can be moved with the standard vi/ moria/ hack movement keys:
  291. X***************
  292. X*** 112,120 ****
  293. X  Once a new town is reached, the player can use the r command here to recruit
  294. X  more troops.
  295. X  
  296. X! Recruitment can only take place every twenty ticks in any given town or
  297. X! city. The exact length of time is found in the file bt.h, in terms of seconds.
  298. X! Also found in bt.h is the constant _SPEED, which determines how often a "tick"
  299. X  takes place, awarding action points and bringing the next recruitment closer.
  300. X  The player can attempt to recruit early, but runs the risk of failure, and
  301. X  will be forced to wait the full time again if recruitment does not succeed.
  302. X--- 122,129 ----
  303. X  Once a new town is reached, the player can use the r command here to recruit
  304. X  more troops.
  305. X  
  306. X! Recruitment can only take place every twenty ticks in any given town or city.
  307. X! Found in bt.h is the constant _SPEED, which determines how often a "tick"
  308. X  takes place, awarding action points and bringing the next recruitment closer.
  309. X  The player can attempt to recruit early, but runs the risk of failure, and
  310. X  will be forced to wait the full time again if recruitment does not succeed.
  311. X***************
  312. X*** 127,132 ****
  313. X--- 136,152 ----
  314. X  army moved. When each tick takes place, the player will receive 2 action
  315. X  points, plus 1 action point for each city under the player's control.
  316. X  
  317. X+ Action points are displayed for each player at the bottom of the screen:
  318. X+ 
  319. X+ A: 6,13
  320. X+ 
  321. X+ This denotes that player A has six hexes (territories) and thirteen
  322. X+ action points.
  323. X+ 
  324. X+ The cursor can be moved freely while considering what command to enter
  325. X+ next. The only time you cannot move the cursor is during the entry of a
  326. X+ number of troops, or a text message to another player.
  327. X+ 
  328. X  COMBAT
  329. X  
  330. X  Combat in the Broken Throne is simple; the player simply moves troops into
  331. X***************
  332. X*** 197,202 ****
  333. X--- 217,224 ----
  334. X    for the locations from which and to which troops are to be moved, then
  335. X    for the number of troops.
  336. X  r (location): recruit troops. See notes above on the rules of recruitment.
  337. X+ M (capitalized): redraw a Messy screen. This is useful after a talk
  338. X+   request messes up your display.
  339. X  
  340. X  WINNING& LOSING
  341. X  
  342. X***************
  343. X*** 233,241 ****
  344. X  
  345. X  SUNVIEW
  346. X  
  347. X! Broken Throne does not run properly under Sunview. This is because curses
  348. X! support for Sunview seems to be broken. If someone is willing to investigate
  349. X! the cause I'll be glad to accommodate a fix.
  350. X  
  351. X  ... Enjoy! Someday I'll make this into a proper man page.
  352. X   
  353. X--- 255,263 ----
  354. X  
  355. X  SUNVIEW
  356. X  
  357. X! Performance under Sunview is a mixed thing, apparently. On our somewhat
  358. X! older Sunview, there are problems with Curses that prevent it from running
  359. X! properly, but under Sunview 3.0 I'm told it works fine.
  360. X  
  361. X  ... Enjoy! Someday I'll make this into a proper man page.
  362. X   
  363. X*** ../../bt/client.c    Fri Nov 16 12:39:46 1990
  364. X--- client.c    Sat Nov 24 10:50:03 1990
  365. X***************
  366. X*** 7,17 ****
  367. X  #include <signal.h>
  368. X  #include <sys/time.h>
  369. X  #include <fcntl.h>
  370. X- #include <stropts.h>
  371. X  #include <errno.h>
  372. X- 
  373. X  #include "types.h"
  374. X  #include "pack.h"
  375. X  #define _MAPX 16
  376. X  #define _MAPY 16
  377. X  
  378. X--- 7,16 ----
  379. X  #include <signal.h>
  380. X  #include <sys/time.h>
  381. X  #include <fcntl.h>
  382. X  #include <errno.h>
  383. X  #include "types.h"
  384. X  #include "pack.h"
  385. X+ #include <ctype.h>
  386. X  #define _MAPX 16
  387. X  #define _MAPY 16
  388. X  
  389. X***************
  390. X*** 52,58 ****
  391. X  int port;
  392. X  int playerFd;
  393. X  int promptoffset;
  394. X! fd_set active;
  395. X  int inputstate;
  396. X  char* host;
  397. X  int connectstream();
  398. X--- 51,58 ----
  399. X  int port;
  400. X  int playerFd;
  401. X  int promptoffset;
  402. X! fd_set server;
  403. X! fd_set term;
  404. X  int inputstate;
  405. X  char* host;
  406. X  int connectstream();
  407. X***************
  408. X*** 87,93 ****
  409. X   char* argv[];
  410. X   {
  411. X   WINDOW* help;
  412. X-  struct strpeek checkio;
  413. X   int inputchar;
  414. X   int inputpos;
  415. X   char inputline[200];
  416. X--- 87,92 ----
  417. X***************
  418. X*** 120,125 ****
  419. X--- 119,125 ----
  420. X   cbreak();
  421. X   noecho();
  422. X   inputstate=_CURSORCOMMAND;
  423. X+  promptplayer("Command:");
  424. X   xsize=COLS/(_MAPX+1);
  425. X   promptoffset=0;
  426. X   if (xsize<4) {
  427. X***************
  428. X*** 133,140 ****
  429. X   signal(SIGTERM,endprogram);
  430. X   signal(SIGCONT,restorescreen);
  431. X   inputfd=fileno(stdin);
  432. X!  /* ioctl(fileno(stdin),I_SETSIG,S_INPUT);
  433. X!  signal(SIGPOLL,inputfork); */
  434. X   fflush(stdin);
  435. X   done=0;
  436. X   inputpos=0;
  437. X--- 133,139 ----
  438. X   signal(SIGTERM,endprogram);
  439. X   signal(SIGCONT,restorescreen);
  440. X   inputfd=fileno(stdin);
  441. X!  FD_SET(inputfd,&term);
  442. X   fflush(stdin);
  443. X   done=0;
  444. X   inputpos=0;
  445. X***************
  446. X*** 145,150 ****
  447. X--- 144,151 ----
  448. X   playernumber=specific[0]-64;
  449. X   sprintf(inputline,"We are player %c.\n",playernumber+64);
  450. X   tellplayer(inputline);
  451. X+  sprintf(inputline,"? summons help.\n");
  452. X+  tellplayer(inputline);
  453. X   while (!getmessage(&messagetype,specific));
  454. X   totalplayers=specific[0]-64;
  455. X   for (count=1; (count<=totalplayers); count++) 
  456. X***************
  457. X*** 224,230 ****
  458. X       }
  459. X     }
  460. X    if (done!=0) {
  461. X!    if (ioctl(inputfd,I_PEEK,&checkio)) {
  462. X       inputchar=getch();
  463. X       if (inputchar=='q')
  464. X         done=2;
  465. X--- 225,231 ----
  466. X       }
  467. X     }
  468. X    if (done!=0) {
  469. X!    if (inputwaiting(&term,inputfd)) {
  470. X       inputchar=getch();
  471. X       if (inputchar=='q')
  472. X         done=2;
  473. X***************
  474. X*** 231,238 ****
  475. X     }
  476. X    }
  477. X    else {
  478. X!    checkio.flags=0;
  479. X!    while (ioctl(inputfd,I_PEEK,&checkio)) {
  480. X      inputchar=getch();
  481. X      switch (inputstate) {
  482. X      case _CURSORM1:
  483. X--- 232,238 ----
  484. X     }
  485. X    }
  486. X    else {
  487. X!    while (inputwaiting(&term,inputfd)) {
  488. X      inputchar=getch();
  489. X      switch (inputstate) {
  490. X      case _CURSORM1:
  491. X***************
  492. X*** 240,245 ****
  493. X--- 240,246 ----
  494. X      case _CURSORRECRUIT:
  495. X      case _CURSORCONSTRUCT:
  496. X      case _CURSORDESTROY:
  497. X+     case _CURSORCOMMAND:
  498. X       switch(inputchar) {
  499. X        case 'h':
  500. X        if (cursorx>0) {
  501. X***************
  502. X*** 305,321 ****
  503. X         }
  504. X         write(playerFd,outputline,strlen(outputline)+1);
  505. X         inputstate=_CURSORCOMMAND;
  506. X         break;
  507. X        }
  508. X        break;
  509. X       }
  510. X!     break;
  511. X!     case _CURSORCOMMAND:
  512. X       switch(inputchar) {
  513. X-       case 'h':
  514. X        case '/':
  515. X        case '?':
  516. X!       help=newwin(16,65,1,5);
  517. X        werase(help);
  518. X        box(help,'|','-');
  519. X        wmove(help,0,0);
  520. X--- 306,323 ----
  521. X         }
  522. X         write(playerFd,outputline,strlen(outputline)+1);
  523. X         inputstate=_CURSORCOMMAND;
  524. X+        promptplayer("Command:");
  525. X         break;
  526. X+        case _CURSORCOMMAND:
  527. X+        tellplayer("Huh?\n");
  528. X        }
  529. X        break;
  530. X       }
  531. X!     if (inputstate==_CURSORCOMMAND) {
  532. X       switch(inputchar) {
  533. X        case '/':
  534. X        case '?':
  535. X!       help=newwin(17,65,1,5);
  536. X        werase(help);
  537. X        box(help,'|','-');
  538. X        wmove(help,0,0);
  539. X***************
  540. X*** 332,338 ****
  541. X        mvwprintw(help,11,1,"Select the location by pressing the space bar or RETURN.");
  542. X        mvwprintw(help,12,1,"t: tell player (player letter): followed by message.");
  543. X        mvwprintw(help,13,1,"Enter a '#' sign instead of a letter to tell all.");
  544. X!       mvwprintw(help,14,1,"Press any key now to continue play.");
  545. X        wrefresh(help);
  546. X        inputchar=getch();
  547. X        delwin(help);
  548. X--- 334,341 ----
  549. X        mvwprintw(help,11,1,"Select the location by pressing the space bar or RETURN.");
  550. X        mvwprintw(help,12,1,"t: tell player (player letter): followed by message.");
  551. X        mvwprintw(help,13,1,"Enter a '#' sign instead of a letter to tell all.");
  552. X!       mvwprintw(help,14,1,"M: (capitalized): redraw Messy screen.");
  553. X!       mvwprintw(help,15,1,"Press any key now to continue play.");
  554. X        wrefresh(help);
  555. X        inputchar=getch();
  556. X        delwin(help);
  557. X***************
  558. X*** 339,344 ****
  559. X--- 342,349 ----
  560. X        touchwin(mapw);
  561. X        wrefresh(mapw);
  562. X        break; 
  563. X+       case 'M':
  564. X+       restorescreen();
  565. X        case 'm':
  566. X        promptplayer("Move: From? ");
  567. X        inputstate=_CURSORM1;
  568. X***************
  569. X*** 370,375 ****
  570. X--- 375,381 ----
  571. X        promptplayer("Tell: whom and what? ");
  572. X        inputstate=_CURSORTELL;
  573. X       }
  574. X+     }
  575. X      break;
  576. X      case _CURSORM3:
  577. X      case _CURSORTELL:
  578. X***************
  579. X*** 414,419 ****
  580. X--- 420,426 ----
  581. X               tellplayer("Huh?\n"); 
  582. X           }
  583. X           inputstate=_CURSORCOMMAND;
  584. X+          promptplayer("Command:");
  585. X           break;
  586. X           case _CURSORM3:
  587. X           outputline[0]=_MOVE;
  588. X***************
  589. X*** 425,430 ****
  590. X--- 432,438 ----
  591. X           outputline[8]=NULL;
  592. X           write(playerFd,outputline,strlen(outputline)+1);
  593. X           inputstate=_CURSORCOMMAND;
  594. X+          promptplayer("Command:");
  595. X           break;
  596. X          }  
  597. X        default:
  598. X***************
  599. X*** 496,502 ****
  600. X    int pos;
  601. X    *messagetype=0;
  602. X    *specific=0;
  603. X!   if (!inputwaiting()) {
  604. X      return 0;
  605. X    }
  606. X    read(playerFd,messagetype,1);
  607. X--- 504,510 ----
  608. X    int pos;
  609. X    *messagetype=0;
  610. X    *specific=0;
  611. X!   if (!inputwaiting(&server,playerFd)) {
  612. X      return 0;
  613. X    }
  614. X    read(playerFd,messagetype,1);
  615. X***************
  616. X*** 517,523 ****
  617. X    current=specific;
  618. X    done=0;
  619. X    while (done==0) {
  620. X!     while (!inputwaiting());
  621. X      read(playerFd,current,1);
  622. X      if (*current==0)
  623. X        done=1;
  624. X--- 525,531 ----
  625. X    current=specific;
  626. X    done=0;
  627. X    while (done==0) {
  628. X!     while (!inputwaiting(&server,playerFd));
  629. X      read(playerFd,current,1);
  630. X      if (*current==0)
  631. X        done=1;
  632. X***************
  633. X*** 613,630 ****
  634. X      perror("connect");
  635. X      return(0);
  636. X    }
  637. X!   FD_SET(s,&active);
  638. X    playerFd=s;
  639. X    return(1);
  640. X  }
  641. X  
  642. X! int inputwaiting() {
  643. X    int errrec;
  644. X    fd_set readfds;
  645. X    struct timeval waitTime;
  646. X    waitTime.tv_sec=SECONDSLIMIT;
  647. X    waitTime.tv_usec=MICROSECONDSLIMIT;
  648. X!   bcopy((char *) &active, (char *) &readfds,sizeof(active));
  649. X    if (select(FD_SETSIZE,&readfds,NULL,NULL,&waitTime)<0) {
  650. X      if (errno!=EINTR) { 
  651. X      perror("select");
  652. X--- 621,641 ----
  653. X      perror("connect");
  654. X      return(0);
  655. X    }
  656. X!   FD_SET(s,&server);
  657. X    playerFd=s;
  658. X    return(1);
  659. X  }
  660. X  
  661. X! int inputwaiting(sfdset,sfd) 
  662. X!   fd_set* sfdset;
  663. X!   int sfd;
  664. X! {
  665. X    int errrec;
  666. X    fd_set readfds;
  667. X    struct timeval waitTime;
  668. X    waitTime.tv_sec=SECONDSLIMIT;
  669. X    waitTime.tv_usec=MICROSECONDSLIMIT;
  670. X!   bcopy((char *) sfdset, (char *) &readfds,sizeof(*sfdset));
  671. X    if (select(FD_SETSIZE,&readfds,NULL,NULL,&waitTime)<0) {
  672. X      if (errno!=EINTR) { 
  673. X      perror("select");
  674. X***************
  675. X*** 631,637 ****
  676. X      }
  677. X      return 0;
  678. X    }
  679. X!   if (FD_ISSET(playerFd,&readfds))
  680. X      return 1;
  681. X    else
  682. X      return 0;
  683. X--- 642,648 ----
  684. X      }
  685. X      return 0;
  686. X    }
  687. X!   if (FD_ISSET(sfd,&readfds))
  688. X      return 1;
  689. X    else
  690. X      return 0;
  691. X***************
  692. X*** 650,658 ****
  693. X    static char outputline[100];
  694. X    move(18,theplayer*10-9);
  695. X    if (players[theplayer].live==1) 
  696. X!     addstr(sprintf(outputline,"%c:%d ,%d ",theplayer+64,
  697. X                     players[theplayer].hexes,players[theplayer].action));
  698. X!   else addstr(sprintf(outputline,"%c: Dead",theplayer+64));
  699. X  }
  700. X  
  701. X  /* get_host_address: borrowed with appreciation from Tinytalk. Does a nice
  702. X--- 661,669 ----
  703. X    static char outputline[100];
  704. X    move(18,theplayer*10-9);
  705. X    if (players[theplayer].live==1) 
  706. X!     addstr(sprintf(outputline,"%c:%d ,%d   ",theplayer+64,
  707. X                     players[theplayer].hexes,players[theplayer].action));
  708. X!   else addstr(sprintf(outputline,"%c: Dead  ",theplayer+64));
  709. X  }
  710. X  
  711. X  /* get_host_address: borrowed with appreciation from Tinytalk. Does a nice
  712. X*** ../../bt/interface.c    Thu Nov 15 00:51:02 1990
  713. X--- interface.c    Sat Nov 24 10:54:25 1990
  714. X***************
  715. X*** 52,60 ****
  716. X  char *curhostname = "";
  717. X  int playerids[20];
  718. X  char outputline[256];
  719. X! void setupinterface() {
  720. X    int current;
  721. X!   init_socket(2727);
  722. X    playertext=(outputline+1);
  723. X    for (current=1; (current<=totalplayers); current++) {
  724. X      playerids[current]=new_player(0);
  725. X--- 52,62 ----
  726. X  char *curhostname = "";
  727. X  int playerids[20];
  728. X  char outputline[256];
  729. X! void setupinterface(portnumber)
  730. X!   int portnumber;
  731. X! {
  732. X    int current;
  733. X!   init_socket(portnumber);
  734. X    playertext=(outputline+1);
  735. X    for (current=1; (current<=totalplayers); current++) {
  736. X      playerids[current]=new_player(0);
  737. X***************
  738. X*** 85,91 ****
  739. X    switch (messagetype) {
  740. X     
  741. X      case _HEXSTATUS:
  742. X!       where=*(location*)details;
  743. X        outputline[1]=64+where.x;
  744. X        outputline[2]=64+where.y;
  745. X        outputline[3]=64+map[where.x][where.y].terrain;
  746. X--- 87,93 ----
  747. X    switch (messagetype) {
  748. X     
  749. X      case _HEXSTATUS:
  750. X!       where=(*(location*)details);
  751. X        outputline[1]=64+where.x;
  752. X        outputline[2]=64+where.y;
  753. X        outputline[3]=64+map[where.x][where.y].terrain;
  754. X***************
  755. X*** 96,102 ****
  756. X        outputline[14]=NULL;
  757. X        break;
  758. X      case _PLAYERSTATUS:
  759. X!       thisplayer=*(int*)details;
  760. X        outputline[1]=thisplayer+64;
  761. X        packint(2,players[thisplayer].action);
  762. X        packint(5,players[thisplayer].hexes);
  763. X--- 98,104 ----
  764. X        outputline[14]=NULL;
  765. X        break;
  766. X      case _PLAYERSTATUS:
  767. X!       thisplayer=(*(int*)details);
  768. X        outputline[1]=thisplayer+64;
  769. X        packint(2,players[thisplayer].action);
  770. X        packint(5,players[thisplayer].hexes);
  771. X***************
  772. X*** 108,114 ****
  773. X        outputline[19]=NULL;
  774. X        break;
  775. X      case _PLAYERDEAD:
  776. X!       thisplayer=*(int*)details;
  777. X        outputline[1]=thisplayer+64;
  778. X        outputline[2]=NULL;
  779. X        break;
  780. X--- 110,116 ----
  781. X        outputline[19]=NULL;
  782. X        break;
  783. X      case _PLAYERDEAD:
  784. X!       thisplayer=(*(int*)details);
  785. X        outputline[1]=thisplayer+64;
  786. X        outputline[2]=NULL;
  787. X        break;
  788. X*** ../../bt/interface.h    Thu Nov  8 05:57:35 1990
  789. X--- interface.h    Sat Nov 24 10:54:48 1990
  790. X***************
  791. X*** 1,4 ****
  792. X! void setupinterface();
  793. X  void shutdowninterface();
  794. X  int getrequest();
  795. X       /* int* player,char* requesttype,char* specific */
  796. X--- 1,4 ----
  797. X! void setupinterface(); /* int portnumber */
  798. X  void shutdowninterface();
  799. X  int getrequest();
  800. X       /* int* player,char* requesttype,char* specific */
  801. XNo differences encountered
  802. XNo differences encountered
  803. XNo differences encountered
  804. X*** /dev/null    Fri Nov 30 17:15:02 1990
  805. X--- changes    Sat Nov 24 11:05:56 1990
  806. X***************
  807. X*** 0 ****
  808. X--- 1,2 ----
  809. X+ See the readme file for a description of changes in version 1.01.
  810. X+ 
  811. X*** /dev/null    Fri Nov 30 17:15:02 1990
  812. X--- robot.c    Sat Nov 24 15:40:32 1990
  813. X***************
  814. X*** 0 ****
  815. X--- 1,348 ----
  816. X+ /* Robot player for Broken Throne- 11/24/90 by Tom Boutell */
  817. X+ 
  818. X+ 
  819. X+ #include <stdio.h>
  820. X+ #include <curses.h>
  821. X+ #include <sys/types.h>
  822. X+ #include <sys/socket.h>
  823. X+ #include <netinet/in.h>
  824. X+ #include <netdb.h>
  825. X+ #include <signal.h>
  826. X+ #include <sys/time.h>
  827. X+ #include <fcntl.h>
  828. X+ #include <errno.h>
  829. X+ #include "types.h"
  830. X+ #include "pack.h"
  831. X+ #include <ctype.h>
  832. X+ #define _MAPX 16
  833. X+ #define _MAPY 16
  834. X+ 
  835. X+ #define _HEXSTATUS 65
  836. X+ #define _PLAYERSTATUS 66
  837. X+ #define _PLAYERDEAD 67
  838. X+ #define _ACTION 68
  839. X+ #define _TEXT 69
  840. X+ #define _STARTUP 70
  841. X+ #define _END 71
  842. X+ #define _YOUARE 72
  843. X+ #define _MOVE 65
  844. X+ #define _RECRUIT 66
  845. X+ #define _QUIT 67
  846. X+ #define _PRIVATE 68
  847. X+ #define _TELLALL 69
  848. X+ #define _DISCONNECT 70
  849. X+ #define _CONSTRUCT 71
  850. X+ #define _DESTROY 72
  851. X+ 
  852. X+ #define SECONDSLIMIT 0L
  853. X+ #define MICROSECONDSLIMIT 1L
  854. X+ hex map[_MAPX][_MAPY];
  855. X+ int lastrecruit[_MAPX][_MAPY];
  856. X+ player players[20];
  857. X+ int playernumber;
  858. X+ player* me;
  859. X+ int totalplayers;
  860. X+ int currenttime;
  861. X+ int living;
  862. X+ int port;
  863. X+ int playerFd;
  864. X+ int promptoffset;
  865. X+ fd_set server;
  866. X+ int inputstate;
  867. X+ char* host;
  868. X+ int connectstream();
  869. X+ int inputwaiting();
  870. X+ void setupmap();
  871. X+ void readnullterm();
  872. X+ void endprogram();
  873. X+ int inrange();
  874. X+ void recruit();
  875. X+ int getmessage();
  876. X+ char specificspace[256];
  877. X+ char outputline[256];
  878. X+ char* specific;
  879. X+ 
  880. X+ main(argc,argv)
  881. X+  int argc;
  882. X+  char* argv[];
  883. X+  {
  884. X+  int done;
  885. X+  char messagetype;
  886. X+  location at;
  887. X+  location from,to;
  888. X+  int theplayer;
  889. X+  int x,y,roll;
  890. X+  int offset;
  891. X+  int count;
  892. X+  if (argc>1) {
  893. X+    host=argv[1];
  894. X+    if (argc>2) 
  895. X+      port=atoi(argv[2]);
  896. X+    else
  897. X+      port=2727;
  898. X+  }
  899. X+  else {
  900. X+    printf("Usage: btclient hostaddress portnumber\n");
  901. X+    exit(1);
  902. X+  }
  903. X+ 
  904. X+  if (connectstream()==0) {
  905. X+    perror("Socket unopenable.\n");
  906. X+    exit(1);
  907. X+  }
  908. X+  setupmap();
  909. X+  done=0;
  910. X+  currenttime=0;
  911. X+  specific=specificspace;
  912. X+  while (!getmessage(&messagetype,specific));
  913. X+  playernumber=specific[0]-64;
  914. X+  me=&players[playernumber];
  915. X+  while (!getmessage(&messagetype,specific));
  916. X+  totalplayers=specific[0]-64;
  917. X+  for (count=1; (count<=totalplayers); count++) 
  918. X+    players[count].live=1;
  919. X+ 
  920. X+  while (done!=2) {
  921. X+    while (getmessage(&messagetype,specific)) {
  922. X+      offset=0;
  923. X+      switch ((int) messagetype) {
  924. X+        case _HEXSTATUS:
  925. X+          striplocation(&at,specific,&offset);
  926. X+          map[at.x][at.y].terrain=specific[offset]-64;
  927. X+          offset++;
  928. X+          stripint(&map[at.x][at.y].population,specific,&offset);
  929. X+          stripint(&map[at.x][at.y].lastuse,specific,&offset);
  930. X+          stripint(&map[at.x][at.y].troops,specific,&offset);
  931. X+          map[at.x][at.y].owner=specific[offset]-64;
  932. X+          offset++;
  933. X+          break;
  934. X+        case _PLAYERSTATUS:
  935. X+          theplayer=specific[offset]-64;
  936. X+          offset++;
  937. X+          stripint(&players[theplayer].action,specific,&offset);
  938. X+          stripint(&players[theplayer].hexes,specific,&offset);
  939. X+          stripint(&players[theplayer].troops,specific,&offset);
  940. X+          stripint(&players[theplayer].population,specific,&offset);
  941. X+          stripint(&players[theplayer].citadels,specific,&offset);
  942. X+          striplocation(&players[theplayer].start,specific,&offset);
  943. X+          break;
  944. X+        case _PLAYERDEAD:
  945. X+          theplayer=specific[0]-64;
  946. X+          players[theplayer].live=0;
  947. X+          for (y=0; (y<_MAPY); y++) {
  948. X+            for (x=0; (x<_MAPX); x++) {
  949. X+              if (map[x][y].owner==theplayer) {
  950. X+                map[x][y].troops=0;
  951. X+                map[x][y].owner=0;
  952. X+              }
  953. X+            }
  954. X+          }
  955. X+          if (theplayer==playernumber) {
  956. X+            done=2;
  957. X+          }
  958. X+          break;
  959. X+        case _TEXT:
  960. X+        case _ACTION:
  961. X+          for (theplayer=1; (theplayer<=totalplayers); theplayer++) {
  962. X+            if (players[theplayer].live==1) {
  963. X+              players[theplayer].action+=(2+players[theplayer].citadels);
  964. X+            }
  965. X+          }
  966. X+          currenttime++;
  967. X+          break;
  968. X+        case _END:
  969. X+          done=2;
  970. X+          break;
  971. X+      }
  972. X+    }
  973. X+   usleep(100000);
  974. X+   /* Now it's time to think. */
  975. X+   /* Sweep our towns and do useful things: */
  976. X+   for (y=0; (y<_MAPY); y++) {
  977. X+     for (x=0; (x<_MAPX); x++) {
  978. X+       if (map[x][y].owner==playernumber) {
  979. X+         if ((map[x][y].terrain==2) || (map[x][y].terrain==5)) {
  980. X+           if ((currenttime-lastrecruit[x][y])>20) {
  981. X+             recruit(x,y);
  982. X+           }
  983. X+         }
  984. X+       }  
  985. X+     }
  986. X+   }         
  987. X+  } 
  988. X+  /* Terminating code - needs to be called on CTRLC also. */
  989. X+  endprogram();
  990. X+ }
  991. X+ 
  992. X+ void recruit(x,y)
  993. X+ int x,y;
  994. X+ {
  995. X+   outputline[0]=_RECRUIT;
  996. X+   outputline[1]=x+64;
  997. X+   outputline[2]=y+64;
  998. X+   outputline[3]=NULL;
  999. X+   write(playerFd,outputline,strlen(outputline)+1);
  1000. X+ }
  1001. X+ 
  1002. X+ void endprogram() {
  1003. X+   outputline[0]=_DISCONNECT;
  1004. X+   outputline[1]=NULL;
  1005. X+   write(playerFd,outputline,strlen(outputline)+1); 
  1006. X+ }
  1007. X+ 
  1008. X+ int inrange(x,low,high)
  1009. X+   int x;
  1010. X+   int low;
  1011. X+   int high;
  1012. X+ {
  1013. X+   if (x<low || x>high)
  1014. X+     return 0;
  1015. X+   return 1;
  1016. X+ }
  1017. X+        
  1018. X+ int getmessage(messagetype,specific)
  1019. X+   char* messagetype;
  1020. X+   char* specific;
  1021. X+ {
  1022. X+   char in;
  1023. X+   int pos;
  1024. X+   *messagetype=0;
  1025. X+   *specific=0;
  1026. X+   if (!inputwaiting(&server,playerFd)) {
  1027. X+     return 0;
  1028. X+   }
  1029. X+   read(playerFd,messagetype,1);
  1030. X+   pos=0;
  1031. X+   readnullterm(playerFd,specific);
  1032. X+   if (*messagetype==0)
  1033. X+     return 0;
  1034. X+   else
  1035. X+     return 1;
  1036. X+ }
  1037. X+ 
  1038. X+ void readnullterm(fd,specific)
  1039. X+   int fd;
  1040. X+   char* specific;
  1041. X+ {
  1042. X+   int done;
  1043. X+   char* current;
  1044. X+   current=specific;
  1045. X+   done=0;
  1046. X+   while (done==0) {
  1047. X+     while (!inputwaiting(&server,playerFd));
  1048. X+     read(playerFd,current,1);
  1049. X+     if (*current==0)
  1050. X+       done=1;
  1051. X+     current++;
  1052. X+   }
  1053. X+ } 
  1054. X+ 
  1055. X+ void setupmap(x,y) 
  1056. X+   int x;
  1057. X+   int y;
  1058. X+ {
  1059. X+   for (y=0; (y<_MAPY); y++) {
  1060. X+     for (x=0; (x<_MAPX); x++) {
  1061. X+       lastrecruit[x][y]=-100;
  1062. X+       map[x][y].terrain=7;
  1063. X+       map[x][y].troops=0;
  1064. X+       map[x][y].population=0;
  1065. X+       map[x][y].owner=0;
  1066. X+       map[x][y].lastuse=0;
  1067. X+     }
  1068. X+   }
  1069. X+ }
  1070. X+ 
  1071. X+ int connectstream()
  1072. X+ {
  1073. X+   int s;
  1074. X+   struct sockaddr_in saddr;
  1075. X+   struct in_addr host_address;
  1076. X+   if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
  1077. X+     perror("socket create");
  1078. X+     return(0);
  1079. X+   }
  1080. X+ 
  1081. X+   saddr.sin_family = AF_INET;
  1082. X+   if (!get_host_address(host,&host_address)) {
  1083. X+     printf("Bad or missing server address.\n");
  1084. X+     exit(1);
  1085. X+   }
  1086. X+   bcopy(&host_address,&saddr.sin_addr,sizeof(struct in_addr));
  1087. X+   /* saddr.sin_addr.s_addr = htonl(inet_addr(host)); Old method */
  1088. X+   saddr.sin_port = htons(port);
  1089. X+ 
  1090. X+   if (connect(s, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in)) < 0) {
  1091. X+     perror("connect");
  1092. X+     return(0);
  1093. X+   }
  1094. X+   FD_SET(s,&server);
  1095. X+   playerFd=s;
  1096. X+   return(1);
  1097. X+ }
  1098. X+ 
  1099. X+ int inputwaiting(sfdset,sfd) 
  1100. X+   fd_set* sfdset;
  1101. X+   int sfd;
  1102. X+ {
  1103. X+   int errrec;
  1104. X+   fd_set readfds;
  1105. X+   struct timeval waitTime;
  1106. X+   waitTime.tv_sec=SECONDSLIMIT;
  1107. X+   waitTime.tv_usec=MICROSECONDSLIMIT;
  1108. X+   bcopy((char *) sfdset, (char *) &readfds,sizeof(*sfdset));
  1109. X+   if (select(FD_SETSIZE,&readfds,NULL,NULL,&waitTime)<0) {
  1110. X+     if (errno!=EINTR) { 
  1111. X+     perror("select");
  1112. X+     }
  1113. X+     return 0;
  1114. X+   }
  1115. X+   if (FD_ISSET(sfd,&readfds))
  1116. X+     return 1;
  1117. X+   else
  1118. X+     return 0;
  1119. X+ }
  1120. X+ 
  1121. X+ 
  1122. X+ /* get_host_address: borrowed with appreciation from Tinytalk. Does a nice
  1123. X+    job of getting around the various stupidities of the inetaddr routine,
  1124. X+    et cetera. */
  1125. X+ 
  1126. X+ int get_host_address(name, addr)        /* Get a host address. */
  1127. X+   register char *name;
  1128. X+   register struct in_addr *addr;
  1129. X+ {
  1130. X+   struct hostent *blob;
  1131. X+   union {                               /* %#@!%!@%#!@ idiot who designed */
  1132. X+     long signed_thingy;                 /* the inetaddr routine.... */
  1133. X+     unsigned long unsigned_thingy;
  1134. X+   } thingy;
  1135. X+ 
  1136. X+   if (*name == '\0') {
  1137. X+     fprintf(stderr, "%% No host address specified.\n");
  1138. X+     return (0);
  1139. X+   }
  1140. X+ 
  1141. X+   if ((*name >= '0') && (*name <= '9')) {       /* IP address. */
  1142. X+     addr->s_addr = inet_addr(name);
  1143. X+     thingy.unsigned_thingy = addr->s_addr;
  1144. X+     if (thingy.signed_thingy == -1) {
  1145. X+       fprintf(stderr, "%% Couldn't find host %s .\n", name);
  1146. X+       return (0);
  1147. X+     }
  1148. X+   }
  1149. X+   else {                                /* Host name. */
  1150. X+     blob = gethostbyname(name);
  1151. X+ 
  1152. X+     if (blob == NULL) {
  1153. X+       fprintf(stderr, "%% Couldn't find host %s .\n", name);
  1154. X+       return (0);
  1155. X+     }
  1156. X+ 
  1157. X+     bcopy(blob->h_addr, addr, sizeof(struct in_addr));
  1158. X+   }
  1159. X+ 
  1160. X+   return (1);                           /* Success. */
  1161. X+ }
  1162. X+ 
  1163. X+ 
  1164. X*** /dev/null    Fri Nov 30 17:15:02 1990
  1165. X--- patchlevel.h    Fri Nov 30 17:17:41 1990
  1166. X***************
  1167. X*** 0 ****
  1168. X--- 1 ----
  1169. X+ #define PATCHLEVEL    1
  1170. END_OF_FILE
  1171. if test 32580 -ne `wc -c <'patches01'`; then
  1172.     echo shar: \"'patches01'\" unpacked with wrong size!
  1173. fi
  1174. # end of 'patches01'
  1175. fi
  1176. echo shar: End of shell archive.
  1177. exit 0
  1178.